﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Chat.Common;

public class GeneralPanelContent:UIBaseContent
{
    public GeneralPanelContent() : base(UIType.GeneralPanelContentType) { }
}

public class GeneralPanel : UIBaseView
{
    public Button enterBtn;
    public InputField inputFieldName;
    private void Awake()
    {
        enterBtn.onClick.AddListener(EnterRoomList);
    }
    // Start is called before the first frame update
    void Start()
    {

    }
    // Update is called once per frame
    private void Update()
    {
        enterBtn.enabled = false;
        if (Singleton<ChatClient>.GetInstance().CurrentState == ClientState.WaitRcving)
            enterBtn.enabled = true;
    }
    public void EnterRoomList()
    {
        Singleton<CommandSender>.GetInstance().SendControlCmd(ControlType.SetOwner, inputFieldName.text);
        Singleton<ContentManager>.GetInstance().Push(new RoomListPanelContent());

    }
    public override void OnEnter(UIBaseContent uIContent)
    {
        GetComponent<BaseCG>().Show();
    }
    public override void OnPause(UIBaseContent uIContent)
    {
        GetComponent<BaseCG>().Hide();
    }
    public override void OnResume(UIBaseContent uIContent)
    {
        GetComponent<BaseCG>().Show();
    }
    public override void OnExit(UIBaseContent uIContent)
    {
        GetComponent<BaseCG>().Hide();
    }
}
